package cn.com.v2.config;

import lombok.Data;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

import java.util.Properties;

/**
 * 七牛云配置
 */
@Data
@Slf4j
public class QiNiuConfig {
    @Getter
    private static QiNiuConfig instance = new QiNiuConfig();
    private String accessKey;
    private String secretKey;
    private String bucket;
    private String domainOfBucket;
    private long expireInSeconds;

    private QiNiuConfig() { //单例设计模式
        Properties prop = new Properties();
        try {
            prop.load(QiNiuConfig.class.getResourceAsStream("/qiniu.properties"));
            accessKey = prop.getProperty("qiniu.access-key");
            secretKey = prop.getProperty("qiniu.secret-key");
            bucket = prop.getProperty("qiniu.bucket");
            expireInSeconds = Long.parseLong(prop.getProperty("qiniu.expire-in-seconds"));
        } catch (Exception e) {
            log.error("读取七牛云配置文件失败！", e);
        }
    }
}
